package com.wanxi.Internet.broad;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.MulticastSocket;
import java.util.UUID;

public class Receive {
    public static void main(String[] args) {
        try {
            System.out.println(UUID.randomUUID().toString() + "广播接收端启动");

            DatagramSocket datagramSocket  = new DatagramSocket(1948);
            byte [] bytes = new byte[1024*64];


            DatagramPacket datagramPacket  = new DatagramPacket(bytes,0,bytes.length);

            datagramSocket.receive(datagramPacket);

            String s = new String(datagramPacket.getData(),0,datagramPacket.getLength());

            System.out.println(s);
            datagramSocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
